﻿using System.Web.Http;
using Eagles.Base;
using Eagles.Interface.Core.News;
using Eagles.Application.Model.News.GetModuleNews;
using Eagles.Application.Model.News.GetNewsDetail;
using Eagles.Application.Model.News.AddNewsViewCount;
using Eagles.Application.Model.News.GetMeeting;
using Eagles.Application.Model.News.GetMeetingDetail;
using Eagles.Application.Model.News.GetPublicUserNews;
using Eagles.Application.Model.News.GetPublicUserNewsDetail;
using Eagles.Application.Model.News.GetUserRequisitionDetail;

namespace Eagles.Application.Host.Controllers
{
    /// <summary>
    /// NewsController
    /// </summary>
    [ValidServiceToken]
    public class NewsController : ApiController
    {
        private INewsHandler newsHandler;

        /// <summary>
        /// NewsController
        /// </summary>
        /// <param name="newsHandler"></param>
        public NewsController(INewsHandler newsHandler)
        {
            this.newsHandler = newsHandler;
        }

        /// <summary>
        /// 更新新闻阅读量
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseFormat<AddNewsViewCountResponse> AddNewsViewCount(AddNewsCountRequest request)
        {
            return ApiActuator.Runing(() => newsHandler.AddNewsViewCount(request));
        }

        /// <summary>
        /// 获取模块内的新闻列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseFormat<GetModuleNewsResponse> GetModuleNews(GetModuleNewsRequest request)
        {
            return ApiActuator.Runing(() => newsHandler.GetModuleNews(request));
        }

        /// <summary>
        /// 新闻详情查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseFormat<GetNewsDetailResponse> GetNewsDetail(GetNewsDetailRequest request)
        {
            return ApiActuator.Runing(() => newsHandler.GetNewsDetail(request));
        }
        
        /// <summary>
        /// 文章公开列表查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseFormat<GetPublicUserNewsResponse> GetPublicUserNews(GetPublicUserNewsRequest request)
        {
            return ApiActuator.Runing(() => newsHandler.GetPublicUserNews(request));
        }

        /// <summary>
        /// 文章公开详情查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseFormat<GetPublicUserNewsDetailResponse> GetPublicUserNewsDetail(GetPublicUserNewsDetailRequest request)
        {
            return ApiActuator.Runing(() => newsHandler.GetPublicUserNewsDetail(request));
        }

        /// <summary>
        /// 会议列表查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseFormat<GetMeetingResponse> GetMeeting(GetMeetingRequest request)
        {
            return ApiActuator.Runing(() => newsHandler.GetMeeting(request));
        }

        /// <summary>
        /// 会议详情查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseFormat<GetMeetingDetailResponse> GetMeetingDetail(GetMeetingDetailRequest request)
        {
            return ApiActuator.Runing(() => newsHandler.GetMeetingDetail(request));
        }
        
        /// <summary>
        /// 入党申请书详情查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseFormat<GetUserRequisitionDetailResponse> GetUserRequisitionDetail(GetUserRequisitionDetailRequest request)
        {
            return ApiActuator.Runing(() => newsHandler.GetUserRequisitionDetail(request));
        }
    }
}